\doxysection{bsp\+\_\+usart.\+h}
\hypertarget{bsp__usart_8h_source}{}\label{bsp__usart_8h_source}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/bsp/usart/bsp\_usart.h@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/bsp/usart/bsp\_usart.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#ifndef\ BSP\_RC\_H}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#define\ BSP\_RC\_H}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <stdint.h>}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{main_8h}{main.h}}"{}}}
\DoxyCodeLine{00006\ }
\DoxyCodeLine{00007\ \textcolor{preprocessor}{\#define\ DEVICE\_USART\_CNT\ 3\ \ \ \ \ }\textcolor{comment}{//\ C板至多分配3个串口}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#define\ USART\_RXBUFF\_LIMIT\ 256\ }\textcolor{comment}{//\ 如果协议需要更大的buff,请修改这里}}
\DoxyCodeLine{00009\ }
\DoxyCodeLine{00010\ \textcolor{comment}{//\ 模块回调函数,用于解析协议}}
\DoxyCodeLine{00011\ \textcolor{keyword}{typedef}\ void\ (*usart\_module\_callback)();}
\DoxyCodeLine{00012\ }
\DoxyCodeLine{00013\ \textcolor{comment}{/*\ 发送模式枚举\ */}}
\DoxyCodeLine{00014\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00015\ \{}
\DoxyCodeLine{00016\ \ \ \ \ USART\_TRANSFER\_NONE=0,}
\DoxyCodeLine{00017\ \ \ \ \ USART\_TRANSFER\_BLOCKING,}
\DoxyCodeLine{00018\ \ \ \ \ USART\_TRANSFER\_IT,}
\DoxyCodeLine{00019\ \ \ \ \ USART\_TRANSFER\_DMA,}
\DoxyCodeLine{00020\ \}\ USART\_TRANSFER\_MODE;}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ \textcolor{comment}{//\ 串口实例结构体,每个module都要包含一个实例.}}
\DoxyCodeLine{00023\ \textcolor{comment}{//\ 由于串口是独占的点对点通信,所以不需要考虑多个module同时使用一个串口的情况,因此不用加入id;当然也可以选择加入,这样在bsp层可以访问到module的其他信息}}
\DoxyCodeLine{00024\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00025\ \{}
\DoxyCodeLine{00026\ \ \ \ \ uint8\_t\ recv\_buff[USART\_RXBUFF\_LIMIT];\ \textcolor{comment}{//\ 预先定义的最大buff大小,如果太小请修改USART\_RXBUFF\_LIMIT}}
\DoxyCodeLine{00027\ \ \ \ \ uint8\_t\ recv\_buff\_size;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 模块接收一包数据的大小}}
\DoxyCodeLine{00028\ \ \ \ \ \mbox{\hyperlink{group___u_a_r_t___exported___types_ga5de4a49eb132735325e706f406c69d6e}{UART\_HandleTypeDef}}\ *usart\_handle;\ \ \ \ \ \ \textcolor{comment}{//\ 实例对应的usart\_handle}}
\DoxyCodeLine{00029\ \ \ \ \ usart\_module\_callback\ module\_callback;\ \textcolor{comment}{//\ 解析收到的数据的回调函数}}
\DoxyCodeLine{00030\ \}\ \mbox{\hyperlink{struct_u_s_a_r_t_instance}{USARTInstance}};}
\DoxyCodeLine{00031\ }
\DoxyCodeLine{00032\ \textcolor{comment}{/*\ usart\ 初始化配置结构体\ */}}
\DoxyCodeLine{00033\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00034\ \{}
\DoxyCodeLine{00035\ \ \ \ \ uint8\_t\ recv\_buff\_size;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 模块接收一包数据的大小}}
\DoxyCodeLine{00036\ \ \ \ \ \mbox{\hyperlink{group___u_a_r_t___exported___types_ga5de4a49eb132735325e706f406c69d6e}{UART\_HandleTypeDef}}\ *usart\_handle;\ \ \ \ \ \ \textcolor{comment}{//\ 实例对应的usart\_handle}}
\DoxyCodeLine{00037\ \ \ \ \ usart\_module\_callback\ module\_callback;\ \textcolor{comment}{//\ 解析收到的数据的回调函数}}
\DoxyCodeLine{00038\ \}\ \mbox{\hyperlink{struct_u_s_a_r_t___init___config__s}{USART\_Init\_Config\_s}};}
\DoxyCodeLine{00039\ }
\DoxyCodeLine{00045\ \mbox{\hyperlink{struct_u_s_a_r_t_instance}{USARTInstance}}\ *\mbox{\hyperlink{bsp__usart_8c_a4296c218240b51944ecb698eed2625ef}{USARTRegister}}(\mbox{\hyperlink{struct_u_s_a_r_t___init___config__s}{USART\_Init\_Config\_s}}\ *init\_config);}
\DoxyCodeLine{00046\ }
\DoxyCodeLine{00052\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{bsp__usart_8c_ac45bba3591501c066f505a46dbae7e2b}{USARTServiceInit}}(\mbox{\hyperlink{struct_u_s_a_r_t_instance}{USARTInstance}}\ *\_instance);}
\DoxyCodeLine{00053\ }
\DoxyCodeLine{00054\ }
\DoxyCodeLine{00065\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{bsp__usart_8c_a12acc10fbb458df894b53534ae66c25d}{USARTSend}}(\mbox{\hyperlink{struct_u_s_a_r_t_instance}{USARTInstance}}\ *\_instance,\ uint8\_t\ *send\_buf,\ uint16\_t\ send\_size,USART\_TRANSFER\_MODE\ mode);}
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00073\ uint8\_t\ \mbox{\hyperlink{bsp__usart_8c_a4a4a562d3a505abe103d09f65ef860e4}{USARTIsReady}}(\mbox{\hyperlink{struct_u_s_a_r_t_instance}{USARTInstance}}\ *\_instance);}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
